package com.hxkj.domain.enums;

import com.platform.common.domain.exception.CustomExceptionCode;

/**
 * 用户异常枚举
 * <p>
 * Created by chenwei on 2017/6/21.
 */
public enum NoticeExceptionEnum implements CustomExceptionCode {
    //异常枚举

    NOTICE_SAVE_ERROR(600, "公告保存异常", 900),
    NOTICE_DELETE_ERROR(601, "公告删除异常", 900),
    NOTICE_QUERY_ERROR(602, "公告获取异常", 900),
    NOTICE_EXIST_ALREADY(603, "公告已存在", 900),
    PARAMETER_IS_NULL(604,"输入参数异常",900),
    NOTICE_IS_NULL(605,"公告不存在",900),
    NOTICETITLE_IS_NULL(606,"公告标题不能为空",900),
    NOTICE_UPDATE_ERROR(607, "公告获取异常", 900),

    ;

    private Integer code;
    private String msg;
    private Integer httpCode;

    NoticeExceptionEnum(Integer code, String msg, Integer httpCode) {
        this.code = code;
        this.msg = msg;
        this.httpCode = httpCode;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public Integer getHttpCode() {
        return httpCode;
    }

    @Override
    public void setHttpCode(Integer httpCode) {
        this.httpCode = httpCode;
    }

    public static NoticeExceptionEnum getEnumByCode(Integer code) {
        for (NoticeExceptionEnum roleExceptionEnum : NoticeExceptionEnum.values()) {
            if (code.equals(roleExceptionEnum.getCode())) {
                return roleExceptionEnum;
            }
        }
        return null;
    }
}
